﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace de.wolfmarco.pas.Shared.MVVM
{
    public class EditWindowInfo
    {
        public EditWindowInfo(Type typeOfContentControl, Type typeOfCurrentObject)
        {
            TypeOfContentControl = typeOfContentControl;
            TypeOfCurrentObject = typeOfCurrentObject;
        }

        public EditWindowInfo(Type typeOfContentControl, object currentObject)
        {
            TypeOfContentControl = typeOfContentControl;
            CurrentObject = currentObject;
        }

        public Type TypeOfContentControl { get; set; }

        private ContentControl currentContentControl;
        public ContentControl CurrentContentControl
        {
            get
            {
                if (currentContentControl==null)
                    currentContentControl = Activator.CreateInstance(TypeOfContentControl, new object[] { CurrentObject }) as ContentControl;
                return currentContentControl;
            }
        }

        private Type typeOfCurrentObject;
        public Type TypeOfCurrentObject
        {
            get { return typeOfCurrentObject; }
            private set
            {
                typeOfCurrentObject = value;
                currentObject = Activator.CreateInstance(value);
            }
        }

        private object currentObject;
        public object CurrentObject
        {
            get { return currentObject; }
            private set
            {
                currentObject = value;
                typeOfCurrentObject = value.GetType();
            }
        }
    }
}
